<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'session.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  	<h1>第一次直接放问session.jsp页面</h1>
    <p>如果是第一次访问此页面session.name为:<span style="color:red"><%=session.getAttribute("name") %>></span></p>
    <h1>通过DemoServlet的doPost方法访问到session.jsp页面</h1>
    <p>此时session.name为:<span style="color:red"><%=session.getAttribute("name") %>></span></p>
    <h1>如果session中有值,刷新此页面,session中的数据会被拿到</h1>
    <p>此时session.name为:<span style="color:red"><%=session.getAttribute("name") %>></span></p>
    <h1>session赋值</h1>
    <p>session.setAttribute("name","我是session中的值")</p>
    <h1>session赋值</h1>
    <p>session.getAttribute("name")</p>
    <h1>清除session中的值</h1>
    <p>session.removeAttribute("name");</p>
    <p>点击一下链接后会清除session中的值,然后再刷新此页面,就会发现session中的值没有了</p>
    <a href="remove.jsp" target="_blank">单击清除session中的值</a>
  </body>
</html>
